﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using TestVisioCanvas.Helpers;

namespace TestVisioCanvas
{
    /// <summary>
    /// Interaction logic for MainSample.xaml
    /// </summary>
    public partial class MainSample : Window
    {
        public MainSample()
        {
            InitializeComponent();
            InitializeDrawingControl(TestVisioCanvas.Helpers.PageStandards.A4OnetoFiftyHorizontalPage);
        }

        private void InitializeDrawingControl(PageSetup setup)
        {
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PageWidth"]
                .set_Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visMillimeters, setup.PageWidth);

            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PageHeight"]
                .set_Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visMillimeters, setup.PageHeight);

            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PageScale"]
                .set_Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visMillimeters, setup.PageScale);

            _drawingControl.Window.PageAsObj.PageSheet.CellsU["DrawingScale"]
                .set_Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visMillimeters, setup.DrawingScale);

            _drawingControl.Window.PageAsObj.PageSheet.CellsU["DrawingScaleType"]
                .ResultIU = 2;
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["DrawingSizetype"]
                .ResultIU = 0;
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["DrawingResizetype"]
                .ResultIU = 2;

            // print setup
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PaperSource"]
                .ResultIU = 7;
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PrintPageOrientation"]
                .ResultIU = 2;
            _drawingControl.Window.PageAsObj.PageSheet.CellsU["PaperKind"]
                .ResultIU = 9;

            _drawingControl.Window.ShowRulers = 1;
            _drawingControl.Window.ShowGrid = 1;
#warning sistemare lo zoom e scrollare la pagina al centro della visualizzazione
            //_drawingControl.Window.Zoom = setup.PreferredZoom;
        }
    }
}
